Lists and Tables

Lists

Lists are very helpful in conveying a set of either numbered or bullet points. This chapter teaches you how to control list type, position, style, etc., using CSS.


We have the following five CSS properties, which can be used to control lists −

1.The list-style-type allows you to control the shape or appearance of the marker.

2.The list-style-position specifies whether a long point that wraps to a second line should align with the first line or start underneath the start of the marker.

3.The list-style-image specifies an image for the marker rather than a bullet point or number.

4.The list-style serves as shorthand for the preceding properties.

5.The marker-offset specifies the distance between a marker and the text in the list.


The list-style-type Property

The list-style-type property allows you to control the shape or style of bullet point (also known as a marker) in the case of unordered lists and the style of numbering characters in ordered lists.


Here is an example-



The list-style-position Property

The list-style-position property indicates whether the marker should appear inside or outside of the box containing the bullet points.


Here is an example-




The list-style-image Property

The list-style-image allows you to specify an image so that you can use your own bullet style. The syntax is similar to the background-image property with the letters url starting the value of the property followed by the URL in brackets. If it does not find the given image then default bullets are used.


Here is an example-

List style property

The list-style allows you to specify all the list properties into a single expression. These properties can appear in any order.


Here is an example-

The marker-offset Property

The marker-offset property allows you to specify the distance between the marker and the text relating to that marker. Its value should be a length as shown in the following example − Unfortunately, this property is not supported in IE 6 or Netscape 7.


Here is an example-

Tables

The look of an HTML table can be greatly improved with CSS.


Table borders

Table width and height

Width and height of a table are defined by the width and height properties. The example below sets the width of the table to 100%, and the height of the elements to 50px:


Table padding

To control the space between the border and the content in a table, use the padding property on and elements: